package src.origintrail;


/**
 * This is a standard player.
 * @author csmythe
 */
public class Player extends Character{
	private PartyMember[] party;
	private Pace wagonSpeed;
	private Rations foodSpeed;
	private Map map;
	private int day;
	private int month;
	private int year;
	/**
	 * An inventory variable...
	 */
	protected Inventory bags;

	/**
	 * Constructor
	 */
	public Player(){
		super();
		bags = new Inventory();
		bags.contents.add(new Wagon().initialize(1));
		bags.contents.add(new Money().initialize(800));
		month = 3;
		day = 1;
		map = new Map("src/origintrail/map/OregonTrail.txt");
		year = 1850;
	}

	/**
	 * Initializer for player
	 * @param name The player's name.
	 * @param partyNames A series of party member names.
	 * @param wagonSpeed The starting pace.
	 * @param foodSpeed The starting food drain.
	 */
	public void initialize(String name, String partyNames[], Pace wagonSpeed, Rations foodSpeed) {
		super.initialize(name);
		this.party = new PartyMember[partyNames.length];
		for (int i = 0; i < party.length; i++)
			this.party[i] = new PartyMember(partyNames[i]);
		this.wagonSpeed = wagonSpeed;
		this.foodSpeed = foodSpeed;
	}

	/**
	 * Possible wagon paces.
	 */
	public enum Pace {
		/**
		 * Stopped
		 */
		STOP(0, "Stop"),			//changed this because i like sleep
		/**
		 * Moving very slowly
		 */
		SLOW(1, "Slow"),
		/**
		 * Medium pace
		 */
		MID(2, "Mid"),				//and this
		/**
		 * Run
		 */
		FAST(3, "Fast");
		/**
		 * 
		 */
		protected double wagonDamage;
		public String name;
                public static String[] list = {"Stopped", "Slow", "Medium", "Fast"};
		Pace(double p, String n){
			wagonDamage = p;
			name = n;
		}
	}

	/**
	 * Getter
	 * @return this.wagonSpeed
	 */
	public Pace getWagonSpeed() {
		return wagonSpeed;
	}
	/**
	 * Sets the Pace of the player
	 * @param wagonSpeed
	 */
	public void setWagonSpeed(Pace wagonSpeed) {
		this.wagonSpeed = wagonSpeed;
	}

	/**
	 * Getter
	 * @return this.foodSpeed
	 */
	public Rations getFoodSpeed() {
		return foodSpeed;
	}
	/**
	 * Getter
	 * @return this.party
	 */
	public PartyMember[] getParty() {
		return party;
	}

	public String partyMemberDies(int member){
		PartyMember[] temp = new PartyMember[party.length - 1];
		for(int i = 0; i < OriginTrail.plr.getParty().length; i++)
			if(i < member)
				temp[i] = OriginTrail.plr.getParty()[i];
			else if(i > member)
				temp[i-1] = OriginTrail.plr.getParty()[i];
		String lostMember = party[member].getName();
		party = temp;
		return lostMember;
	}

	/**
	 * Resets the rations consumption
	 * @param food new this.foodSpeed
	 */
	public void setFoodSpeed(Rations food) {
		this.foodSpeed = food;
	}

	/**
	 * Getter
	 * @return this.map
	 */
	public Map getMap() {
		return map;
	}

	/**
	 * Setter
	 * @param day
	 */
	public void setDay(int day) {
		this.day = day;
	}
	/**
	 * Setter
	 * @param month
	 */
	public void setMonth(int month) {
		this.month = month;
	}
	/**
	 * Setter
	 * @param year
	 */
	public void setYear(int year)
	{
	this.year = year;
	}
	/**
	 * Getter
	 * @return this.year
	 */
	public int getYear()
	{
		return year;
	}
	/**
	 * formats date
	 * @return x 
	 */
	public String getDate() 
	{	String x = "";
		int numDays = 0;
		switch (month)
		{
		case 1:
			x = "January ";
			break;
		case 2:
			x = "February ";
			break;
		case 3:
			x = "March ";
			break;
		case 4:
			x = "April ";
			break;
		case 5:
			x = "May ";
			break;
		case 6:
			x = "June ";
                        break;
		case 7:
			x = "July ";
			break;
		case 8: 
			x = "August ";
			break;
		case 9: 
			x = "September ";
			break;
		case 10:
			x = "October ";
			break;
		case 11:
			x = "November ";
			break;
		case 12:
			x = "December ";
			break;
		}
		return (x + day + ", " + year);
	}
	
	/**
	 * Getter
	 * @return day
	 */
	public int getDay() {
		return day;
	}
	/**
	 * Getter
	 * @return month
	 */
	public int getMonth() {
		return month;
	}

	/**
	 * Changed debug toString()
	 * @return A representation of this object
	 */
	@Override
	public String toString(){
		String s = this.getName() + "\n";
		for(PartyMember p : party)
			s+= p.getName() + "\n";
				s+= this.wagonSpeed + "\n";
				s+= this.foodSpeed;
				return s;
	}

	public void setParty(PartyMember[] party) {
		this.party = party;
	}

	/**
	 * The food consumption rate
	 */
	public enum Rations{

		/**
		 * No consumption
		 */
		STARVING(0, "Starving"),           //and theeeeeese  o.o
		/**
		 * 1 meal a day
		 */
		FRUGAL(1, "Frugal"),
		/**
		 * Morning and evening meals
		 */
		NORMAL(2, "Normal"),
		/**
		 * Three meals a day
		 */
		WELLFED(3, "Wellfed");
		/**
		 * Handles the cost of food on a day-to-day basis. Used for bonuses.
		 */
		protected double foodCost;
		public String name;
                public static String[] list = {"Starving", "Frugal", "Normal", "Well-fed"};
		Rations(double f, String n){
			foodCost = f;
			name = n;
		}
	}

}

